package tech.aistar.day01;

import java.sql.*;

public class StudentJdbcTest {
    public static void main(String[] args) {
        Connection conn=null;
        Statement st=null;
        ResultSet rs=null;

        try{
            Class.forName("com.mysql.cj.jdbc.Driver");

            String url="jdbc:mysql://localhost:3306/kd?useSSL=false";
            String user="root";
            String password="root";

            conn= DriverManager.getConnection(url,user,password);
            st=conn.createStatement();
            String sql="select * from student where id=1";
            rs=st.executeQuery(sql);

            if(rs.next()){
                int id=rs.getInt(1);
                String name=rs.getString(2);
                int age=rs.getInt(3);
                Student s=new Student(id,name,age);
            }
        }catch (ClassNotFoundException e){
            e.printStackTrace();
        }catch (SQLException e){
            e.printStackTrace();
        }

    }
}
